Skip to content
This repository has been archived by the owner on Mar 13, 2022. It is now read-only.

fix stream data decoding #112

Closed
wants to merge 45 commits into from
Closed

fix stream data decoding #112

wants to merge 45 commits into from

Conversation

dbazhal
Copy link

@dbazhal dbazhal commented Jan 21, 2019

Related to #88 and #104
I suppose decoding complete data is better than decoding data chunks.
Would be nice to get review from @mbohlool and @saberuster

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please email the CNCF helpdesk: [email protected]

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jan 21, 2019
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 21, 2019
@dbazhal
Copy link
Author

dbazhal commented Jan 23, 2019

Ok, i think I now signed the cla, hope the bot will reconcile that.

juliantaylor and others added 2 commits January 23, 2019 19:38
The watch code reset the version to the last found in the
response.
When you first list existing objects and then start watching from that
resource version the existing versions are older than the version you
wanted and the watch starts from the wrong version after the first
restart.
This leads to for example already deleted objects ending in the stream
again.

Fix this by setting the minimum resource version to reset from to the
input resource version. As long as k8s returns all objects in order in
the watch this should work.
We cannot use the integer value of the resource version to order it as
one should be treat the value as opaque.

Closes kubernetes-client/python#700
fix watching with a specified resource version
@dbazhal
Copy link
Author

dbazhal commented Jan 31, 2019

@roycaihw or @micw523 or @yliaog guys, mb any of you could take a look at my pr, or #104 please? don't want to patch this in all my controllers, and with current amount of objects in crds they fail with unicode decode errors like every hour :D

index = data.find("\n")
newline_symbol = "\n"
if six.PY3:
newline_Symbol = b"\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it does the same thing, I wonder why you applied different logic compared to Line 44. Also, be careful about your variable name: do you mean newline_symbol instead of a capitalized S?

Copy link
Author

@dbazhal dbazhal Jan 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uh-oh, my bad, fixed that. i'll test this code tomorrorow.
and it'd be great if you could judge the solution to decoding errors itself, it bothers me more than anything else :) maybe you will find solution from #104 better than this one

@micw523
Copy link
Contributor

micw523 commented Jan 31, 2019

Also, it doesn't seem like your CLA has been updated yet. You sure you signed it?

tx to micw comments
@dbazhal
Copy link
Author

dbazhal commented Jan 31, 2019

Also, it doesn't seem like your CLA has been updated yet. You sure you signed it?

thought i signed it. now signed for sure, and email/uid match. i hope bot will recognize that

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jan 31, 2019
```
Traceback (most recent call last):
  File "controller_unitproject/run.py", line 33, in <module>
    run()
  File "controller_unitproject/run.py", line 29, in run
    unitproject.run()
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/module_k8s_controller_sdk/controller.py", line 215, in run
    self.resync_and_watch()
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/module_k8s_controller_sdk/controller.py", line 209, in resync_and_watch
    from_version=last_known_resource_version
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/module_k8s_controller_sdk/watcher.py", line 92, in watch
    self.__watch(seconds_to_out)
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/module_k8s_controller_sdk/watcher.py", line 51, in __watch
    for event in stream:
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/kubernetes/watch/watch.py", line 130, in stream
    for line in iter_resp_lines(resp):
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/kubernetes/watch/watch.py", line 47, in iter_resp_lines
    seg = seg.decode('utf8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 2047: unexpected end of data
```
@dbazhal
Copy link
Author

dbazhal commented Feb 1, 2019

Fixed one more bug about decoding - now inside watch.py.
All changes tested and work fine 👍

@roycaihw
Copy link
Member

roycaihw commented Feb 4, 2019

commented in #104 (comment). I think we should decode utf8 only if opcode is Text

@dbazhal
Copy link
Author

dbazhal commented Mar 25, 2019

Hey guys, what else can I do to help with this one? @roycaihw ?

@leavest leavest mentioned this pull request Apr 20, 2019
@dbazhal
Copy link
Author

dbazhal commented May 16, 2019

I dunno if it is acceptable to up threads, but it would be nice to get any answer ^_^

@roycaihw
Copy link
Member

@dbazhal sorry for the late reply. I will review this pull this week

@dbazhal
Copy link
Author

dbazhal commented Jun 6, 2019

just another firendly reminder :)

@roycaihw
Copy link
Member

@dbazhal my apologies.. was busy with k/k 1.15 freeze. Please take a look at #104 (comment). I think recv_data_frame handles fragment concatenation already, so we don't have to concatenate the messages on top of that

dbazhal and others added 10 commits June 20, 2019 20:53
Related to #88 and #104
I suppose decoding complete data is better than decoding data chunks.
tx to micw comments
```
Traceback (most recent call last):
  File "controller_unitproject/run.py", line 33, in <module>
    run()
  File "controller_unitproject/run.py", line 29, in run
    unitproject.run()
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/module_k8s_controller_sdk/controller.py", line 215, in run
    self.resync_and_watch()
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/module_k8s_controller_sdk/controller.py", line 209, in resync_and_watch
    from_version=last_known_resource_version
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/module_k8s_controller_sdk/watcher.py", line 92, in watch
    self.__watch(seconds_to_out)
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/module_k8s_controller_sdk/watcher.py", line 51, in __watch
    for event in stream:
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/kubernetes/watch/watch.py", line 130, in stream
    for line in iter_resp_lines(resp):
  File "/home/bajal/.local/share/virtualenvs/controller_unitproject-1u3cbEWP/lib/python3.7/site-packages/kubernetes/watch/watch.py", line 47, in iter_resp_lines
    seg = seg.decode('utf8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 2047: unexpected end of data
```
Following comment #112 (comment)
Tested on running controller.
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dbazhal
To complete the pull request process, please assign roycaihw
You can assign the PR to them by writing /assign @roycaihw in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 20, 2019
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please log a ticket with the Linux Foundation Helpdesk: https://support.linuxfoundation.org/
  • Should you encounter any issues with the Linux Foundation Helpdesk, send a message to the backup e-mail support address at: [email protected]

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 20, 2019
@dbazhal dbazhal closed this Jun 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.